home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / bash_completion.d / cfengine < prev    next >
Encoding:
Text File  |  2010-11-16  |  2.2 KB  |  89 lines

  1. # bash completion for cfengine
  2.  
  3. have cfagent && {
  4. _cfagent_options()
  5. {
  6.     COMPREPLY=( $( compgen -W '--sysadm --force-net-copy --no-check-files \
  7.         --no-check-mounts --debug --define --no-edits --enforce-links --file \
  8.         --help --no-hard-classes --no-ifconfig --inform --no-copy --no-lock \
  9.         --traverse-links --delete-stale-links --no-mount --no-modules \
  10.         --dry-run --negate --parse-only --no-processes --no-splay \
  11.         --no-commands --silent --no-tidy --use-env --underscore-classes \
  12.         --verbose --version --no-preconf --no-links --quiet' -- "$cur" ) )
  13. }
  14.  
  15. _cfagent()
  16. {
  17.     local cur prev
  18.  
  19.     COMPREPLY=()
  20.     _get_comp_words_by_ref cur prev
  21.  
  22.     case $prev in
  23.         -f|--file)
  24.             _filedir
  25.             return 0
  26.             ;;
  27.     esac
  28.  
  29.     if [[ "$cur" == -* ]]; then
  30.         _cfagent_options
  31.     fi
  32. }
  33. complete -F _cfagent cfagent
  34.  
  35. _cfrun()
  36. {
  37.     local i section cfinputs cur prev
  38.  
  39.     COMPREPLY=()
  40.     _get_comp_words_by_ref cur prev
  41.  
  42.     section=1
  43.     for (( i=1; i < COMP_CWORD; i++ )); do
  44.         if [[ "${COMP_WORDS[i]}" == -- ]]; then
  45.             section=$((section + 1))
  46.         fi
  47.     done
  48.  
  49.     case $section in
  50.         1)
  51.             case $prev in
  52.                 -f)
  53.                     _filedir
  54.                     return 0
  55.                     ;;
  56.             esac
  57.  
  58.             if [[ "$cur" == -* ]]; then
  59.                 COMPREPLY=( $( compgen -W '-f -h -d -S -T -v' -- $cur ) )
  60.             else
  61.                 hostfile=${CFINPUTS:-/var/lib/cfengine/inputs}/cfrun.hosts
  62.                 for (( i=1; i < COMP_CWORD; i++ )); do
  63.                     if [[ "${COMP_WORDS[i]}" == -f ]]; then
  64.                         hostfile=${COMP_WORDS[i+1]}
  65.                         break
  66.                     fi
  67.                 done
  68.                 [ ! -f $hostfile ] && return 0
  69.  
  70.                 COMPREPLY=( $(compgen -W  "$( command grep -v \
  71.                     -E '(=|^$|^#)' $hostfile )" -- "$cur" ) )
  72.             fi
  73.             ;;
  74.         2)
  75.             _cfagent_options
  76.             ;;
  77.     esac
  78. }
  79. complete -F _cfrun cfrun
  80. }
  81.  
  82. # Local variables:
  83. # mode: shell-script
  84. # sh-basic-offset: 4
  85. # sh-indent-comment: t
  86. # indent-tabs-mode: nil
  87. # End:
  88. # ex: ts=4 sw=4 et filetype=sh
  89.